package com.alcloud.springplus.base;


/**
  * 
  * @className:      ResponseData
  * @description:    统一返回值
  * @date:           2018/12/5 9:26
  * @author:         AllG
  * @updateRemark:   更新说明
 */
public class ResponseData<T> {
	/** 错误或者成功代码 */
	private int code;
	/** 错误描述 */
	private String message;
	/** 响应结果*/
	private T data;
	
	/**
	 * 构造函数
	 */
	public ResponseData() {
	}

	/**
	 * @method  ResponseData
	 * @description 通过状态、信息构建
	 * @date: 2018/12/5 9:31
	 * @author: AllG
	 * @param code
	 * @param message
	 * @return 
	 */
	public ResponseData(int code, String message) {
		this.code = code;
		this.message = message;
	}

	/**
	 * @method  ResponseData
	 * @description 通过状态码、信息、传入数据构建
	 * @date: 2018/12/5 9:31
	 * @author: AllG
	 * @param code
	 * @param message
	 * @param data
	 * @return 
	 */
	public ResponseData(int code, String message, T data) {
		this.code = code;
		this.message = message;
		this.data = data;
	}

	/**
	 * @method  ResponseData
	 * @description 通过ResponseCode数据构建
	 * @date: 2018/12/5 9:30
	 * @author: AllG
	 * @param responseCode
	 * @return
	 */
	public ResponseData(ResponseCode responseCode) {
		this.code = responseCode.getCode();
		this.message = responseCode.getMessage();
	}


	/**
	 * @method  ResponseData
	 * @description 通过ResponseCode、传入数据数据构建
	 * @date: 2018/12/5 9:30
	 * @author: AllG
	 * @param responseCode
     * @param data
	 * @return
	 */
	public ResponseData(ResponseCode responseCode, T data) {
		this.code = responseCode.getCode();
		this.message = responseCode.getMessage();
		this.data = data;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}
}
